﻿@{
    ViewBag.Title = "message";
    Layout = "~/Views/Shared/Template.cshtml";
}

@using Partner.MVC.Models;
@{
    var user = Session["LoginUser"] as User_Info;
}

<div style="height: 300px;width: 100%;background:url(/static/hbweb/images/me.jpg);">
    <div class="container">
        <div class="header-message">
            <img class="fl" src="http://pic.huobanchina.com/o_1bp7omfg8e821pc4bbg1u8g1ifl9.jpeg" alt="" />
            <div class="fl header-text">
                <h3 class="user-name">@user.Use_Name </h3>
                <i class="icon-fabu3 point user-namei"></i>
            </div>
            <a id="AlterPwd" style="width:85px;" data-toggle="modal" data-target="#myModal" class="fr fn-font-hover-blue change change-password">
                修改密码
            </a>
        </div>
    </div>
</div>

<div class="bgcSil">
    <div class="container">
        <div class="mt30" style="width: 100%">
            <ul id="divLeft" style="width:24%" class="nav navbar-nav"></ul>
            <div id="divContent" style="width:75%;" class="fr mb80 cont bgcWhit news-list-con">
                <div class="bgcWhit neirong">
                    @foreach (var a in Model)
                    {
                    <ul class="incontent will-del">
                        <li class="fcBlack pr" style="height:40px; line-height:40px; padding:20px;">
                            <div class="title clearfix">
                                <p class="pr fl">
                                    <i data-id='85457a3b0a124a7eb264baa3f3b68c3c' class="slect ding"></i>
                                    <a style="cursor:pointer;" onclick="location.href = '/UserCenter/messageXX?id='+@a.M_Id"> @a.M_Title</a>
                                </p>
                                &nbsp;&nbsp;&nbsp;&nbsp;
                                <i class="fn-hide unread fn-font-clor-red">new</i><span></span>
                                <p class="fr">
                                    @a.M_Time
                                    <span class="badge">
                                        @{
                        var name = @a.IsDel == 0 ? "新" : "已读";
                                        }
                                        @name
                                    </span>
                                    <span>
                                        @*<input id="DelMessage" onclick="del" type="button" value="删除记录" />*@
                                        <a onclick="del(@a.M_Id)">删除记录</a>
                                    </span>
                                </p>
                            </div>
                        </li>
                    </ul>
                    }
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 左侧导航-->
<script>
    ParentNav();
    // 绑定根节点
    function ParentNav() {
        $.ajax({
            type: "post",
            url: "/Partner/LeftNav",
            dataType: "json",
            success: function (data) {
                var htmltab = "";
                for (var i = 0; i < data.length; i++) {
                    htmltab += "<li class=\"dropdown\"><a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\" style=\"width: 175px;font-size: 16px;\">" + data[i].Lar_Name + "</a>" + SonNav(data[i].Limit_Id) + "</li>";
                }
                $("#divLeft").append(htmltab);
            },
            error: function (err) {
                alert(err);
            }
        })
    }
    // 绑定子节点
    function SonNav(id) {
        var html1 = "";
        $.ajax({
            type: "post",
            url: "/Partner/LeftSon",
            data: { pid: id },
            dataType: "json",
            async: false,
            success: function (data) {
                var strhtml = "<ul class=\"dropdown-menu\">"
                for (var i = 0; i < data.length; i++) {
                    strhtml += "<li><a href=\"" + data[i].Limit_Url + "\">" + data[i].Limit_Name + "</a></li>"
                }
                strhtml += "</ul>";
                html1 = strhtml;
            }
        })
        return html1;
    }

    // 删除消息
    function del(id) {
        if (confirm('确定要删除吗？')) {
            $.ajax({
                type: "post",
                url: "/UserCenter/DelMessage",
                data: { M_Id: id },
                success: function (obj) {
                    if (obj > 0) {
                        window.location.reload();
                    }
                    else {
                        alert('删除失败')
                    }
                }
            })
        }
    }
</script>

